/**
 * 
 */
Ext.define("wufe.util.map.MapMeasureLengthTool", {

	extend : 'OpenLayers.Control.Measure',

	mixins : {
		map_measuretool : 'wufe.util.map.MapMeasureTool',
		map_plugincommand : 'wufe.util.map.MapPluginCommand'
	},

	// 定义类 初始化函数

	constructor : function(p_mapClass) {
		this.init(p_mapClass);
		//   
		var handler = OpenLayers.Handler.Path;
		this.handlerOptions = handler;
		//
		// 测量控制操作
		var sketchSymbolizers = {
			"Point" : {
				graphicName : "cross",
				graphicHeight : 8,
				graphicWidth : 8,
				fillColor : "#FF0000",
				fillOpacity : 1,
				strokeWidth : 0
			},
			"Line" : {
				strokeWidth : 1.5,
				strokeOpacity : 1,
				strokeColor : "#0000FF"
			},
			"Polygon" : {
				strokeWidth : 1.5,
				strokeOpacity : 1,
				strokeColor : "#0000FF",
				fillColor : "#ccccff",
				fillOpacity : 0.3
			}
		};

		var style = new OpenLayers.Style();
		style.addRules([new OpenLayers.Rule({
					symbolizer : sketchSymbolizers
				})]);
		var styleMap = new OpenLayers.StyleMap({
					"default" : style
				});

		var renderer = OpenLayers.Util.getParameters(window.location.href).renderer;
		renderer = (renderer)
				? [renderer]
				: OpenLayers.Layer.Vector.prototype.renderers;

		var options = {
			persist : true,
			handlerOptions : {
				style : "default",
				layerOptions : {
					renderers : renderer,
					styleMap : styleMap
				}
			}
		};
		// 初始化父类的构造函数
		map_plugincommand.prototype.initialize.apply(this, [p_mapClass,
						handler, options]);
		OpenLayers.Control.Measure.prototype.initialize.apply(this, [handler,
						options]);
		//
		this.handler = new handler(this, this.callbacks, this.handlerOptions);
		//
		this.events.on({
			"measure" : map_measuretool.handleMeasure, // 测量距离完成的时候
			"measurepartial" : map_measuretool.handleMeasurePartial
				// 测量距离加入一个点的时候
			});

	}
});